package robotleMvc.frameworks.scene3D.model
{
	import _Pan3D.base.Camera3D;
	import _Pan3D.base.Focus3D;
	import _Pan3D.core.MathCore;
	
	import _me.Scene_data;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display3D.Context3D;
	import flash.display3D.Context3DTextureFormat;
	
	import org.robotlegs.mvcs.Actor;
	
	import robotleMvc.frameworks.glass.GlassEvent;
	import robotleMvc.frameworks.scene3D.event.Scene3DEvent;
	
	public class Scene3DModel extends Actor
	{
		[Embed(source="../_File/nijia2/dengguang1.jpg")]
		private var pic:Class;
		
		public function Scene3DModel()
		{
			super();
		}
		public var showGlassView:Boolean=false;
		public var showFireView:Boolean;
		public function initData(context3D:Context3D):void
		{
			Scene_data.funToScanShodar=makeShadeTime;
			
			makeSceneLightText();	
		}
		private function makeSceneLightText():void
		{
			var context3D:Context3D=Scene_data.context3D
		    var tempBmp:BitmapData=Bitmap(new pic()).bitmapData;
			Scene_data.sceneLightText=context3D.createTexture(tempBmp.width,tempBmp.height, Context3DTextureFormat.BGRA,true);
			Scene_data.sceneLightText.uploadFromBitmapData(tempBmp);
			 
		}
		private function makeShadeTime():void
		{
			//加载完成，显示阴影
			this.dispatch(new Scene3DEvent(Scene3DEvent.GET_SHODAR_BITMAPDATA));
			showGlassView=!showGlassView;
			this.dispatch(new GlassEvent(GlassEvent.UP_NEW_GLASS_INFO_PIC));
			this.dispatch(new Scene3DEvent(Scene3DEvent.GET_GROUND_HEIGHT_BITMAPDATA));

		}
		public function makeLightCam():void
		{
			var fous3D:Focus3D=Scene_data.focus3D.cloneFocus3D();
			fous3D.angle_x=-90;
			fous3D.angle_y=0;
			//fous3D.x=0;
			//fous3D.y=0;
			//fous3D.z=0;
			var cam3D:Camera3D=Scene_data.light3D;
			cam3D.distance=2000;
			cam3D.fovw=1024;
			cam3D.fovh=1024;
			MathCore._catch_cam(cam3D, fous3D);
			
			//cam3D.toString();
	
		
		}

	}
}